<?php
include_once("../module/micro_stock/includes/plugin_micro_stock_class.php");
$microStock = new MicroStock();

if(!($_GET['memberId']>0)){
    $memberId = 0;
}else{
    $memberId = $_GET['memberId'];
}

$field = "a.`member_id`,a.`pid`,a.`num`,a.`stock_shop`,a.`create_time`,a.`update_time`,b.`pname`,b.`spec`,b.`pic`,c.`title` as shop_name";
$cond = " and a.`member_id`={$memberId} ";

if($_GET['stock_shop']){
    $cond .= " and a.`stock_shop`={$_GET['stock_shop']} ";
}
if($_GET['product_id']){
    $cond .= " and a.`pid` in(".trim(trim($_GET['product_id']),',').") ";
}

//=============================
include_once("../includes/page_utf_class.php");
$page = new Page;
$page->listRows=20;
if (!$page->__get('totalRows')){
    $de['count']=$page->totalRows = $microStock->getMemberStockProductsTotalNum($cond);//总数
}
$de['count']=$de['count']?$de['count']:($_GET['totalRows']?$_GET['totalRows']:'0');
$de['page'] = $page->prompt();
$de['perPageRows'] = $page->listRows;
//=============================

//列表数据
$de['list'] = $microStock->getMemberStockProductsList($field,$cond,'',$page->firstRow,$page->listRows);

if(!empty($de['list'])){
    foreach ($de['list'] as $k=>$v)
    {
        if(strpos($v['pic'],',')!==false){
            $de['list'][$k]['pic'] = strstr($v['pic'], ',', true);
        }
    }
}

$tpl->assign('de',$de);
$tpl->display('micro_stock_products.htm');